package com.maowei.handler;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.otter.canal.protocol.CanalEntry;
import com.maowei.event.TableEvent;
import com.maowei.parser.RowDataCustomParser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 示例 : 监听用户变的数据变化 !!!
 * 示例 : 监听用户变的数据变化 !!!
 * 示例 : 监听用户变的数据变化 !!!
 * <p>
 * 监听 新增和修改的变化
 *
 * @author maowei
 * @date 2021/8/25
 */
@Slf4j
@Component
@TableEvent(schemaName = "test", tableName = "sys_user", tableComment = "用户表",
        eventTypes = CanalEntry.EventType.UPDATE, focusColumns = {"user_name"})
public class SysUserEventHandler extends BaseEventHandler {

    @Autowired
    public SysUserEventHandler(RowDataCustomParser rowDataCustomParser) {
        super(rowDataCustomParser);
    }

    @Override
    public void doHandle(JSONObject jsonObject) {
//        dataLog(jsonObject);
//        BusinessOperateRecordModel businessOperateRecordModel = this.parse(jsonObject, false, new String[]{"user_name"});
//        toDB(businessOperateRecordModel);
//        log.info("用户表 - 修改操作记录 : {}", businessOperateRecordModel);
        // 新版注解式处理等同于如上代码
        super.doHandle(jsonObject);
    }
}
